Back

Dynamic News

 

On August 14, 2003 around 4:00 pm the lights went out in the Big Apple, Detroit and parts of Canada.
Really cool CD
Blah blah blah Links Can Be Added

This is a nice little script to flash news or product info.  Its not to difficult to configure.  It comes in two parts.

Place script between the <HEAD></HEAD> tags.

Width Height Speed Link Image/Text Headline
<style type="text/css">

#newsflashsubject{
width: 250px;
font-weight: bold;
}

.newsflash{
width: 250px;
height: 100px;
border: 1px solid black;
background-color: #FFFFFF;
padding: 5px;
display:block;
}

</style>

<script type="text/javascript">


var tickspeed=4000
var enablesubject=1

if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.newsflash{display:none;}\n')
document.write('</style>\n')
}

var selectedDiv=0
var totalDivs=0

function contractall(){
var inc=0
while (document.getElementById("dropmsg"+inc)){
document.getElementById("dropmsg"+inc).style.display="none"
inc++
}
}


function expandone(){
var selectedDivObj=document.getElementById("dropmsg"+selectedDiv)
contractall()
document.getElementById("newsflashsubject").innerHTML=selectedDivObj.getAttribute("subject")
selectedDivObj.style.display="block"
selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0
setTimeout("expandone()",tickspeed)
}

function startscroller(){
while (document.getElementById("dropmsg"+totalDivs)!=null)
totalDivs++
expandone()
if (!enablesubject)
document.getElementById("newsflashsubject").style.display="none"
}

if (window.addEventListener)
window.addEventListener("load", startscroller, false)
else if (window.attachEvent)
window.attachEvent("onload", startscroller)

</script>
<style fprolloverstyle>A:hover {color: #FF0000; font-family: Arial}
</style>
 

Place where needed in the body of the HTML Document.

<div id="newsflashsubject"></div>

<div id="dropmsg0" class="newsflash" subject="Power Goes Out in New York.">
On August 14, 2003 around 4:00 pm the lights went out in the Big Apple, Detroit and parts of Canada.
</div>

<div id="dropmsg1" class="newsflash" subject="Free Javascripts .">
Really cool CD<br>
<img border="0" src="images/BS00789_.wmf" width="50" height="50">

</div>

<div id="dropmsg2" class="newsflash" subject="Yet Another News Headline.">
Blah blah blah <a href="#">Links Can Be Added</a>
</div>
 

Place script between the <HEAD></HEAD> tags.


Paste script where needed in the body of the HTML Document.


© Copyright 2009 ashesh.com.np